<template>
  <el-dialog
      v-model="diaVisible"
      title="光照强度"
      :close-on-click-modal="false"
      :append-to-body="true"
      width="520px"
      @close="resetForm"
  >
    <div style="text-align: center; margin-top: 20px">
      <div style="display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 14px">
<!--        <div>当前设置光照值为: {{autoStatusData.LIGHTNESS}}</div>-->
<!--        <div>当前铁路自动化数据库连接状态为: {{autoStatusData.DATABASEFLAG ? '异常' : '正常'}}</div>-->

        <div>当前设置光照值：{{ autoStatusData.LIGHTNESS }}</div>
        <div>当前实测光照值：{{ autoStatusData.currentLightness }}</div>
      </div>
      <el-select v-model="num" placeholder="请选择">
        <el-option :label="key" :value="value" v-for="(value,key) in list" />
      </el-select>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <div @click="submitForm" class="sure-btn" style="margin-right: 10px">确认</div>
        <div @click="resetForm" class="cancel-btn">取消</div>
      </div>
    </template>
  </el-dialog>
</template>

<script>
import {cronAutoFlag, getLightness, setLightness} from "../../../router/api.js";
import {mapGetters} from "vuex";

export default {
  name: "onSiteInspection",
  computed: {
    ...mapGetters(['autoStatusData']),
  },
  data(){
    return {
      diaVisible: false,
      num: '',
      list: []
    }
  },
  methods:{
    async show(){
      this.diaVisible = true;
      let res = await getLightness();
      if(res.data.code == 200){
        this.list = res.data.data;
      }
    },
    submitForm() {
      if(!this.num){
        this.$message.warning('请选择');
        return;
      }
      setLightness({lightness: this.num}).then(res => {
        if(res.data.code == 200){
          this.resetForm();
        }
      })
    },
    resetForm() {
      this.num = '';
      this.diaVisible = false;
    },
  }
}
</script>

<style scoped>

</style>
